home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / recover / analyzeTrans.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.8 KB  |  184 lines

  1. /*
  2.  *   $RCSfile: analyzeTrans.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:55 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "semaphore.h"
  52. #include "latch.h"
  53. #include "link.h"
  54. #include "lsn.h"
  55. #include "bf.h"
  56. #include "volume.h"
  57. #include "openlog.h"
  58. #include "trans.h"
  59. #include "logrecs.h"
  60. #include "util_funcs.h"
  61. #include "log_intfuncs.h"
  62. #include "log_extfuncs.h"
  63. #include "recover_intfuncs.h"
  64. #include "recover_extfuncs.h"
  65. #include "trans_extfuncs.h"
  66. #include "thread_globals.h"
  67. #include "trans_globals.h"
  68. #include "distr.h"
  69. #include "distr_globals.h"
  70.  
  71.  
  72.  void
  73. analyzeTrans (
  74.  
  75.     register LOGRECORDHDR    *record,
  76.     register LSN            *recordLSN 
  77. )
  78. {
  79.     
  80.     register TRANSREC        *transRec;
  81.  
  82.  
  83.     TRPRINT(TR_LOG|TR_RECOVER, TR_LEVEL_1, ("recordLSN:%d tid:%x type:%d action:%d",
  84.             recordLSN->offset, record->tid, record->type, record->action));
  85.  
  86.     /*
  87.      *    check to see if there is a transaction record
  88.      */
  89.     if ((transRec = findTransRec(record->tid)) == NULL)    {
  90.  
  91.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("tid not found"));
  92.  
  93.         /*
  94.          *    allocate a transaction record
  95.          */
  96.         if ((transRec = allocRecoveryTrans()) == NULL)    {
  97.  
  98.             SM_ERROR(TYPE_FATAL, esmINTERNAL);
  99.         }
  100.  
  101.         /*
  102.          *    hang the transaction off the hash table
  103.          */
  104.         listPush( &(TransHashTable[HASH_TID(record->tid)]), &(transRec->tidList) );
  105.  
  106.         /*
  107.          *    fill in the transaction information
  108.          */
  109.         transRec->tid = record->tid;
  110.         transRec->firstLSN = *recordLSN;
  111.     }
  112.  
  113.     /*
  114.      *    fill in the last lsn
  115.      *    Also fill in the first LSN if it is not already set.  This
  116.      *    will be the case if the transaction had no log records
  117.      *    generated when the checkpoint was taken.
  118.      */
  119.     transRec->lastLSN = recordLSN->offset;
  120.     if (transRec->firstLSN.offset == NULL_LSN) transRec->firstLSN = *recordLSN;
  121.     TRPRINT(TR_RECOVER, TR_LEVEL_2, ("lastLSN:%d", transRec->lastLSN));
  122.  
  123.     /*
  124.      *    check to see if the record is compensation or regular
  125.      */
  126.     switch (record->type)    {
  127.  
  128.         case LOG_REC_TYPE_USER:
  129.         case LOG_REC_TYPE_USER_COMPENSATION:
  130.  
  131.             TRPRINT(TR_RECOVER, TR_LEVEL_2, ("type user"));
  132.  
  133.             /*
  134.              *    check to see if the record is undoable
  135.              */
  136.             if (!(record->flags & REDO_ONLY))    {
  137.             
  138.                 TRPRINT(TR_RECOVER, TR_LEVEL_2, ("not redo only: nextUndoLSN:%d", recordLSN->offset));
  139.                 transRec->nextUndoLSN = recordLSN->offset;
  140.             }
  141.             break;
  142.  
  143.         case LOG_REC_TYPE_COMPENSATION:
  144.  
  145.             TRPRINT(TR_RECOVER, TR_LEVEL_2, ("type compensation"));
  146.  
  147.             /*
  148.              *    fill in the next undo lsn
  149.              */
  150.             transRec->nextUndoLSN = record->nextUndoLSN;
  151.             TRPRINT(TR_RECOVER, TR_LEVEL_2, ("nextUndoLSN:%d", transRec->nextUndoLSN));
  152.             /*
  153.              *    for distr trans - see if the trans is prepared 
  154.              *    this would mean that this transaction was being
  155.              *    aborted - we don't expect any such records for
  156.              *    coord transactions though
  157.              */
  158.             if ((transRec->transState == T_PREPARED) && 
  159.                 (LIST_MEMBER(&(transRec->distrTransList)))) {
  160.                 /*
  161.                  *  take it off the list of active distr transactions
  162.                   */
  163.                  listRemove( &(transRec->distrTransList) );
  164.  
  165.                 /*
  166.                   *  decrement the number of active distr transactions
  167.                   */
  168.                 numActiveServerDistrTrans--;
  169.  
  170.                 /*
  171.                  *    change the state back to recover so that 
  172.                  *    recoverUndo won't barf
  173.                  */
  174.                 transRec->transState = T_RECOVER;
  175.             }
  176.             break;
  177.  
  178.         default:
  179.  
  180.             TRPRINT(TR_RECOVER, TR_LEVEL_2, ("other record type"));
  181.             break;
  182.     }
  183. }
  184.